package com.ak.helloword_1;

import com.ak.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;

import java.io.IOException;

public class Provider {
    public static void main(String[] args) {

        // 获取连接对象 生产者----> 队列
        try {
            Connection connection= RabbitMQUtils.getConnection();
            Channel channel=connection.createChannel();
            channel.queueDeclare("hello",true,false,false,null);
            // MessageProperties.PERSISTENT_TEXT_PLAIN 消息持久化
            channel.basicPublish("","hello", MessageProperties.PERSISTENT_TEXT_PLAIN,"hello rabbit".getBytes());
            RabbitMQUtils.closeConnectionAndChanel(channel,connection);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

        }

    }
}

